<?php

class Wx
{
    function getWxAccess_token()
    {
          if(session('access_token') && session("expirce")>time()){
                 $access_token =  session('access_token');
                 return $access_token;
          }else{
              $appid = C('wx')['APPID'];
              $appserct = C("wx")['AppSecret'];
              $url ="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appserct."";
              $res = GoCurl($url,'GET');
              $res = json_decode($res,true);
              session('access_token',$res['access_token']);
              session('expirce',time()+7000);
              return $res['access_token'];
          }
    }
}